<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-10-29 14:56:33
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 工序收货，染色收货，倒毛收货
 */

namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\MaterialTrait;
use App\Traits\StorageTrait;
use App\Traits\CarryTrait;
use App\Traits\CarTrait;

class ProProcessesInspect extends BaseModel
    {
    use MaterialTrait;
    use AutoCodeTrait;
    use StorageTrait;
    public $timestamps = true;
    public $table = "sys_pro_processes_inspect";
    protected $guarded = [];
    protected $casts = [];
    // 
    protected $ACSign = 'INSPECT_PROCESS';
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'InStorage');
            });
        }

    public function order()
        {
        return $this->belongsTo(CustomerStorageDetail::class);
        }
    public function pack()
        {
        return $this->hasMany(ProProcessesInspectPack::class, "inspect_id");
        }
    public function wip()
        {
        return $this->belongsTo(ProProcessesWip::class);
        }
    public function open_card()
        {
        return $this->belongsTo(OpenCardDetails::class);
        }
    public function process()
        {
        return $this->belongsTo(ProProcesses::class);
        }
    public function _updated($model)
        {
        $model->order->updateQuantity();
        }
    }
